﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.ComponentModel.DataAnnotations;

namespace SCWLib
{
    /// <summary>
    /// THis class is use to create dummy data, which involve 
    /// different datatype
    /// </summary>
    public class ShareChiWai_Model
    {

        public DataTable Get_Food_Tbl()
        {
            DataTable tbl = new DataTable();
            //Demostrate Auto-Increment Column
            //Create a new Data Column
            DataColumn Col_ID = new DataColumn();
            //Set the DataType to Int
            Col_ID.DataType = System.Type.GetType("System.Int32");
            //Assign Column Name
            Col_ID.ColumnName = "ID";
            //Set Column Property as Read Only
            Col_ID.ReadOnly = true;
            //Set Column Property as 
            Col_ID.Unique = true;
            // Add the Column to the DataColumnCollection.
            tbl.Columns.Add(Col_ID);

            tbl.Columns.Add(new DataColumn("Food_ID", Type.GetType("System.String")));
            tbl.Columns.Add(new DataColumn("Food_Name", Type.GetType("System.String")));
            tbl.Columns.Add(new DataColumn("Price", Type.GetType("System.Decimal")));
            tbl.Columns.Add(new DataColumn("FoodCategory_ID", Type.GetType("System.String")));

            DataRow dr1 = tbl.NewRow();
            dr1["Food_ID"] = "00001";
            dr1["Food_Name"] = "Apple";
            dr1["Price"] = 0.99;
            dr1["FoodCategory_ID"] = "00001";
            tbl.Rows.Add(dr1);

            DataRow dr2 = tbl.NewRow();
            dr2["Food_ID"] = "00002";
            dr2["Food_Name"] = "American bison";
            dr2["Price"] = 7.99;
            dr2["FoodCategory_ID"] = "00002";
            tbl.Rows.Add(dr2);



            tbl.Rows.Add(new Object[] { "00003", "Asparagus", 3.99, "00003" });
            tbl.Rows.Add(new Object[] { "00004", "Banana", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00005", "Beef", 1.99, "00002" });
            tbl.Rows.Add(new Object[] { "00006", "Broccoli", 1.09, "00003" });
            tbl.Rows.Add(new Object[] { "00007", "Cherry", 1.99, "00001" });
            //start Vegetable
            tbl.Rows.Add(new Object[] { "00008", "Yams", 1.99, "00003" });
            tbl.Rows.Add(new Object[] { "00009", "Sweet potatoes", 5.99, "00003" });
            tbl.Rows.Add(new Object[] { "00010", "Olives", 5.99, "00003" });
            tbl.Rows.Add(new Object[] { "00011", "Tomato", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00012", "Spinach", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00013", "Radish", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00014", "Pumpkin", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00015", "Onion", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00016", "Nopales ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00017", "Mushrooms ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00018", "Leeks ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00019", "Kohlrabi ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00020", "Japanese Eggplant ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00021", "Hot Pepper", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00022", "Garlic", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00023", "Fordhooks ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00024", "Eggplant ", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00025", "Dinosaur Kale", 0.99, "00003" });
            tbl.Rows.Add(new Object[] { "00026", "Cabbage ", 0.99, "00003" });
            //End Vegetable
            tbl.Rows.Add(new Object[] { "00027", "Cattle", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00028", "Duck", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00029", "E -- Unknown", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00030", "Fugu", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00031", "Guinea pig", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00032", "Zebra", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00033", "Whale", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00034", "Tuna", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00035", "Salmon", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00036", "Pork", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00037", "Orange Roughy", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00038", "Milkfish", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00039", "Kingfish", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00040", "Watermelon", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00041", "Strawberries", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00042", "Raspberries", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00043", "Raisins", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00044", "Prunes", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00045", "Plums", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00046", "Haddock", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00047", "Nutria", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00048", "Lamb", 0.99, "00002" });
            tbl.Rows.Add(new Object[] { "00049", "Iguana", 0.99, "00002" });

            //fruit continue
            tbl.Rows.Add(new Object[] { "00050", "Orange", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00051", "Mango", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00052", "Kiwi", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00053", "Lime", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00054", "Jackfruit", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00055", "Guava", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00056", "Grapefruit", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00057", "Fig", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00058", "Durian", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00059", "Papaya", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00060", "Ugli Fruit", 0.99, "00001" });
            tbl.Rows.Add(new Object[] { "00061", "Tamarillo", 0.99, "00001" });
            //Fruit End
            tbl.Rows.Add(new Object[] { "00099", "Asparagus Apple Sample Long Name", 3.99, "00003" });


            return tbl;
        }
        public List<Food> Get_Food_List()
        {
            List<Food> Food_List = new List<Food>();
            DataTable tbl = Get_Food_Tbl();

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                Food_List.Add(new Food()
                {
                    FoodCategory_ID = (string)tbl.Rows[i]["FoodCategory_ID"],
                    Food_ID = (string)tbl.Rows[i]["Food_ID"],
                    Food_Name = (string)tbl.Rows[i]["Food_Name"],
                    Price = (decimal)tbl.Rows[i]["Price"]

                });
            }
            return Food_List;

        }

        public List<FoodCategory> Get_Food_Categories_List()
        {
            List<FoodCategory> Categories_List = new List<FoodCategory>();
            DataTable tbl = Get_Food_Categories();

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                Categories_List.Add(new FoodCategory()
                {
                    FoodCategory_ID = (string)tbl.Rows[i]["FoodCategory_ID"],
                    FoodCategory_Name = (string)tbl.Rows[i]["FoodCategory_Name"]

                });
            }
            return Categories_List;

        }

        public DataTable Get_Food_Categories()
        {
            DataTable tbl = new DataTable();
            tbl.Columns.Add(new DataColumn("FoodCategory_ID", Type.GetType("System.String")));
            tbl.Columns.Add(new DataColumn("FoodCategory_Name", Type.GetType("System.String")));

            DataRow dr1 = tbl.NewRow();
            dr1["FoodCategory_ID"] = "00001";
            dr1["FoodCategory_Name"] = "Fruit";
            tbl.Rows.Add(dr1);

            DataRow dr2 = tbl.NewRow();
            dr2["FoodCategory_ID"] = "00002";
            dr2["FoodCategory_Name"] = "Meat/Animal";
            tbl.Rows.Add(dr2);
            DataRow dr3 = tbl.NewRow();
            dr3["FoodCategory_ID"] = "00003";
            dr3["FoodCategory_Name"] = "Vegetable";
            tbl.Rows.Add(dr3);

            return tbl;
        }


        public List<Food> Get_FoodByCategoryID_List(string FoodCategory_ID)
        {
            List<Food> Food_List = new List<Food>();
            DataTable tbl = Get_FoodByCategoryID(FoodCategory_ID);

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                Food_List.Add(new Food()
                {
                    FoodCategory_ID = (string)tbl.Rows[i]["FoodCategory_ID"],
                    Food_ID = (string)tbl.Rows[i]["Food_ID"],
                    Food_Name = (string)tbl.Rows[i]["Food_Name"],
                    Price = (decimal)tbl.Rows[i]["Price"]

                });
            }
            return Food_List;

        }
        public DataTable Get_FoodByCategoryID(string FoodCategory_ID)
        {

            DataTable tbl = new DataTable();
            DataRow[] dr_Array = Get_Food_Tbl().Select("FoodCategory_ID ='" + FoodCategory_ID + "'");



            if (dr_Array.Length > 0)
            {

                tbl = dr_Array[0].Table.Copy();

                tbl.Clear();
            }

            foreach (DataRow dr in dr_Array)
            {

                tbl.ImportRow(dr);
            }

            return tbl;
        }
    }

    public class FoodCategory
    {


        public string FoodCategory_ID { get; set; }

        public string FoodCategory_Name { get; set; }
    }
    public class Food
    {
        public string Food_ID { get; set; }
        public string Food_Name { get; set; }
        public decimal Price { get; set; }
        [Display(Name = "Food Category ID")]
        public string FoodCategory_ID { get; set; }
    }

    public class FoodCategoryMain_Model
    {
        public List<FoodCategory> FoodCategory_List { get; set; }
        public FoodCategory FoodCategory_Detail { get; set; }
    }

    /// <summary>
    /// Selection Options
    /// </summary>
    public class FoodCategory_SelectionOptions_Model
    {
        public List<FoodCategory> FoodCategory_List { get; set; }
        public List<Food> Food_List { get; set; }
    }


}
